﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 类_构造与析构
{
    class Program
    {
        static void Main(string[] args)
        {
            Time t1 = new Time();
            t1.Show();
            Time t2 = new Time(2, 34, 34);
            t2.Show();
        }
  
    }
    public class Time
    {
        private int hour;
        private int minute;
        private int second;

        public void Show()
        {
            Console.WriteLine("{0:D2}:{1:D2}:{2:D2}", hour, minute, second);
        }
        public Time()
        {
            hour = minute = second = 0;
            Console.WriteLine("Default Destruct");
        }
        public Time(int h,int m,int s)
        {
            hour = h >= 0 && h <= 24 ? h : 0;
            minute = m >= 0 && m <= 59 ? m : 0;
            second = s >= 0 && s <= 59 ? s : 0;
            Console.WriteLine("Cestruct");
        }
        ~Time()
        {
            Console.WriteLine("Destruct");
        }
    }
}
